import Home from '@/views/Home'
import Search from '@/views/Search'
import NotFound from '@/views/NotFound'
import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter) // VueRouter插件初始化

// 创建了一个路由对象
const router = new VueRouter({
  mode: 'history',
  routes: [
    // 记单词：以发音作为最小记忆单位，而不是以字母作为最小单位
    { path: '/', redirect: '/home' },
    { path: '/home', component: Home },
    // { name: 'search', path: '/search', component: Search },
    { name: 'search', path: '/search/:words', component: Search },
    // VueRouter 在初始化的时候，会自动将 * 通配符路由规则 移动到最后
    { path: '*', component: NotFound },
  ]
})

export default router